package com.cykj.feign.impl;

import com.cykj.dto.ResponseDTO;
import com.cykj.feign.GoodControllerFeign;
import com.cykj.vo.CyGoodVO;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author 王宇
 * @CreateTime: 2025-08-04  10:28
 * @BelongsProject: jd_seckill
 * @BelongsPackage: com.cykj.feign.impl
 * @description 熔断降级回调工厂接口实现
 */
@Component
public class GoodControllerFeignFactoryImpl implements FallbackFactory<GoodControllerFeign> {
    @Override
    public GoodControllerFeign create(Throwable e) {
        e.printStackTrace();  // 打印异常消息
        System.out.println("发生熔断");
        return new GoodControllerFeign() {
            @Override
            public ResponseDTO subGoodStock(CyGoodVO cyGoodVO) {
                // 具体措施自己写
                return ResponseDTO.error("采用降级措施");
            }
        };
    }
}
